package networking.assignments;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Scanner;

public class Client2 {

	public static void main(String[] args) throws UnknownHostException,
			IOException, SocketException {
		Socket s = new Socket("localhost", 1811);

		Scanner sc = new Scanner(System.in);

		System.out.print("login: ");
		String userName = sc.next();

		System.out.print("password: ");
		String password = sc.next();

		Credentials obj = new Credentials(userName, password);

		ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
		out.writeObject(obj);

		DataInputStream in = new DataInputStream(s.getInputStream());
		System.out.println(in.readUTF());

		out.close();
		in.close();
		s.close();
	}
}
